home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / URLAccess.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  10.6 KB  |  345 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        URLAccess.h
  3.  
  4.      Contains:    URL Access Interfaces.
  5.  
  6.      Version:    Technology:    URLAccess 2.0
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1994-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __URLACCESS__
  18. #define __URLACCESS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25.     #include <Files.h>
  26. #endif
  27.  
  28. #ifndef __CODEFRAGMENTS__
  29.     #include <CodeFragments.h>
  30. #endif
  31.  
  32. #ifndef __FILESIGNING__
  33.     #include <FileSigning.h>
  34. #endif
  35.  
  36. #ifndef __MACERRORS__
  37.     #include <MacErrors.h>
  38. #endif
  39.  
  40.  
  41.  
  42.  
  43. #if PRAGMA_ONCE
  44. #pragma once
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. #if PRAGMA_IMPORT
  52. #pragma import on
  53. #endif
  54.  
  55. #if PRAGMA_STRUCT_ALIGN
  56.     #pragma options align=mac68k
  57. #elif PRAGMA_STRUCT_PACKPUSH
  58.     #pragma pack(push, 2)
  59. #elif PRAGMA_STRUCT_PACK
  60.     #pragma pack(2)
  61. #endif
  62.  
  63. /* Data structures and types */
  64. typedef struct OpaqueURLReference*         URLReference;
  65.  
  66. typedef UInt32 URLOpenFlags;
  67. enum {
  68.     kURLReplaceExistingFlag        = 1 << 0,
  69.     kURLBinHexFileFlag            = 1 << 1,                        /* Binhex before uploading if necessary*/
  70.     kURLExpandFileFlag            = 1 << 2,                        /* Use StuffIt engine to expand file if necessary*/
  71.     kURLDisplayProgressFlag        = 1 << 3,
  72.     kURLDisplayAuthFlag            = 1 << 4,                        /* Display auth dialog if guest connection fails*/
  73.     kURLUploadFlag                = 1 << 5,                        /* Do an upload instead of a download*/
  74.     kURLIsDirectoryHintFlag        = 1 << 6,                        /* Hint: the URL is a directory*/
  75.     kURLDoNotTryAnonymousFlag    = 1 << 7,                        /* Don't try to connect anonymously before getting logon info*/
  76.     kURLDirectoryListingFlag    = 1 << 8,                        /* Download the directory listing, not the whole directory*/
  77.     kURLExpandAndVerifyFlag        = 1 << 9,                        /* Expand file and then verify using signature resource*/
  78.     kURLNoAutoRedirectFlag        = 1 << 10,                        /* Do not automatically redirect to new URL*/
  79.     kURLDebinhexOnlyFlag        = 1 << 11,                        /* Do not use Stuffit Expander - just internal debinhex engine*/
  80.     kURLReservedFlag            = 1 << 31                        /* reserved for Apple internal use*/
  81. };
  82.  
  83.  
  84. typedef UInt32 URLState;
  85. enum {
  86.     kURLNullState                = 0,
  87.     kURLInitiatingState            = 1,
  88.     kURLLookingUpHostState        = 2,
  89.     kURLConnectingState            = 3,
  90.     kURLResourceFoundState        = 4,
  91.     kURLDownloadingState        = 5,
  92.     kURLDataAvailableState        = 0x10 + kURLDownloadingState,
  93.     kURLTransactionCompleteState = 6,
  94.     kURLErrorOccurredState        = 7,
  95.     kURLAbortingState            = 8,
  96.     kURLCompletedState            = 9,
  97.     kURLUploadingState            = 10
  98. };
  99.  
  100.  
  101. typedef UInt32 URLEvent;
  102. enum {
  103.     kURLInitiatedEvent            = kURLInitiatingState,
  104.     kURLResourceFoundEvent        = kURLResourceFoundState,
  105.     kURLDownloadingEvent        = kURLDownloadingState,
  106.     kURLAbortInitiatedEvent        = kURLAbortingState,
  107.     kURLCompletedEvent            = kURLCompletedState,
  108.     kURLErrorOccurredEvent        = kURLErrorOccurredState,
  109.     kURLDataAvailableEvent        = kURLDataAvailableState,
  110.     kURLTransactionCompleteEvent = kURLTransactionCompleteState,
  111.     kURLUploadingEvent            = kURLUploadingState,
  112.     kURLSystemEvent                = 29,
  113.     kURLPercentEvent            = 30,
  114.     kURLPeriodicEvent            = 31,
  115.     kURLPropertyChangedEvent    = 32
  116. };
  117.  
  118. typedef unsigned long                     URLEventMask;
  119. enum {
  120.     kURLInitiatedEventMask        = 1 << (kURLInitiatedEvent - 1),
  121.     kURLResourceFoundEventMask    = 1 << (kURLResourceFoundEvent - 1),
  122.     kURLDownloadingMask            = 1 << (kURLDownloadingEvent - 1),
  123.     kURLUploadingMask            = 1 << (kURLUploadingEvent - 1),
  124.     kURLAbortInitiatedMask        = 1 << (kURLAbortInitiatedEvent - 1),
  125.     kURLCompletedEventMask        = 1 << (kURLCompletedEvent - 1),
  126.     kURLErrorOccurredEventMask    = 1 << (kURLErrorOccurredEvent - 1),
  127.     kURLDataAvailableEventMask    = 1 << (kURLDataAvailableEvent - 1),
  128.     kURLTransactionCompleteEventMask = 1 << (kURLTransactionCompleteEvent - 1),
  129.     kURLSystemEventMask            = 1 << (kURLSystemEvent - 1),
  130.     kURLPercentEventMask        = 1 << (kURLPercentEvent - 1),
  131.     kURLPeriodicEventMask        = 1 << (kURLPeriodicEvent - 1),
  132.     kURLPropertyChangedEventMask = 1 << (kURLPropertyChangedEvent - 1),
  133.     kURLAllBufferEventsMask        = kURLDataAvailableEventMask + kURLTransactionCompleteEventMask,
  134.     kURLAllNonBufferEventsMask    = kURLInitiatedEventMask + kURLDownloadingMask + kURLUploadingMask + kURLAbortInitiatedMask + kURLCompletedEventMask + kURLErrorOccurredEventMask + kURLPercentEventMask + kURLPeriodicEventMask + kURLPropertyChangedEventMask,
  135.     kURLAllEventsMask            = (long)0xFFFFFFFF
  136. };
  137.  
  138.  
  139.  
  140. struct URLCallbackInfo {
  141.     UInt32                             version;
  142.     URLReference                     urlRef;
  143.     const char *                    property;
  144.     UInt32                             currentSize;
  145.     EventRecord *                    systemEvent;
  146. };
  147. typedef struct URLCallbackInfo            URLCallbackInfo;
  148. static const char* kURLURL                        = "URLString";
  149. static const char* kURLResourceSize                = "URLResourceSize";
  150. static const char* kURLLastModifiedTime            = "URLLastModifiedTime";
  151. static const char* kURLMIMEType                    = "URLMIMEType";
  152. static const char* kURLFileType                    = "URLFileType";
  153. static const char* kURLFileCreator                = "URLFileCreator";
  154. static const char* kURLCharacterSet                = "URLCharacterSet";
  155. static const char* kURLResourceName                = "URLResourceName";
  156. static const char* kURLHost                        = "URLHost";
  157. static const char* kURLAuthType                    = "URLAuthType";
  158. static const char* kURLUserName                    = "URLUserName";
  159. static const char* kURLPassword                    = "URLPassword";
  160. static const char* kURLStatusString                = "URLStatusString";
  161. static const char* kURLIsSecure                    = "URLIsSecure";
  162. static const char* kURLCertificate                = "URLCertificate";
  163. static const char* kURLTotalItems                = "URLTotalItems";
  164. /* http and https properties*/
  165. static const char* kURLHTTPRequestMethod        = "URLHTTPRequestMethod";
  166. static const char* kURLHTTPRequestHeader        = "URLHTTPRequestHeader";
  167. static const char* kURLHTTPRequestBody            = "URLHTTPRequestBody";
  168. static const char* kURLHTTPRespHeader            = "URLHTTPRespHeader";
  169. static const char* kURLHTTPUserAgent            = "URLHTTPUserAgent";
  170. static const char* kURLHTTPRedirectedURL        = "URLHTTPRedirectedURL";
  171. /* authentication type flags*/
  172. enum {
  173.     kUserNameAndPasswordFlag    = 0x00000001
  174. };
  175.  
  176. EXTERN_API( OSStatus )
  177. URLGetURLAccessVersion            (UInt32 *                returnVers);
  178.  
  179. #if TARGET_RT_MAC_CFM
  180. #ifdef __cplusplus
  181.     inline pascal Boolean URLAccessAvailable() { return ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) ); }
  182. #else
  183.     #define URLAccessAvailable()     ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) )
  184. #endif
  185. #elif TARGET_RT_MAC_MACHO
  186. /* URL Access is always available on OS X */
  187. #ifdef __cplusplus
  188.     inline pascal Boolean URLAccessAvailable() { return true; }
  189. #else
  190.     #define URLAccessAvailable()     (true)
  191. #endif
  192. #endif  /*  */
  193.  
  194. typedef CALLBACK_API( OSStatus , URLNotifyProcPtr )(void *userContext, URLEvent event, URLCallbackInfo *callbackInfo);
  195. typedef CALLBACK_API( OSStatus , URLSystemEventProcPtr )(void *userContext, EventRecord *event);
  196. typedef TVECTOR_UPP_TYPE(URLNotifyProcPtr)                         URLNotifyUPP;
  197. typedef TVECTOR_UPP_TYPE(URLSystemEventProcPtr)                 URLSystemEventUPP;
  198. #if OPAQUE_UPP_TYPES
  199.     EXTERN_API(URLNotifyUPP)
  200.     NewURLNotifyUPP                   (URLNotifyProcPtr        userRoutine);
  201.  
  202.     EXTERN_API(URLSystemEventUPP)
  203.     NewURLSystemEventUPP           (URLSystemEventProcPtr    userRoutine);
  204.  
  205.     EXTERN_API(void)
  206.     DisposeURLNotifyUPP               (URLNotifyUPP            userUPP);
  207.  
  208.     EXTERN_API(void)
  209.     DisposeURLSystemEventUPP       (URLSystemEventUPP        userUPP);
  210.  
  211.     EXTERN_API(OSStatus)
  212.     InvokeURLNotifyUPP               (void *                    userContext,
  213.                                     URLEvent                event,
  214.                                     URLCallbackInfo *        callbackInfo,
  215.                                     URLNotifyUPP            userUPP);
  216.  
  217.     EXTERN_API(OSStatus)
  218.     InvokeURLSystemEventUPP           (void *                    userContext,
  219.                                     EventRecord *            event,
  220.                                     URLSystemEventUPP        userUPP);
  221.  
  222. #else
  223.     #define NewURLNotifyUPP(userRoutine)                            (userRoutine)
  224.     #define NewURLSystemEventUPP(userRoutine)                        (userRoutine)
  225.     #define DisposeURLNotifyUPP(userUPP)                             
  226.     #define DisposeURLSystemEventUPP(userUPP)                         
  227.     #define InvokeURLNotifyUPP(userContext, event, callbackInfo, userUPP)  (*userUPP)(userContext, event, callbackInfo)
  228.     #define InvokeURLSystemEventUPP(userContext, event, userUPP)     (*userUPP)(userContext, event)
  229. #endif
  230. EXTERN_API( OSStatus )
  231. URLSimpleDownload                (const char *            url,
  232.                                  FSSpec *                destination,
  233.                                  Handle                 destinationHandle,
  234.                                  URLOpenFlags             openFlags,
  235.                                  URLSystemEventUPP         eventProc,
  236.                                  void *                    userContext);
  237.  
  238. EXTERN_API( OSStatus )
  239. URLDownload                        (URLReference             urlRef,
  240.                                  FSSpec *                destination,
  241.                                  Handle                 destinationHandle,
  242.                                  URLOpenFlags             openFlags,
  243.                                  URLSystemEventUPP         eventProc,
  244.                                  void *                    userContext);
  245.  
  246. EXTERN_API( OSStatus )
  247. URLSimpleUpload                    (const char *            url,
  248.                                  const FSSpec *            source,
  249.                                  URLOpenFlags             openFlags,
  250.                                  URLSystemEventUPP         eventProc,
  251.                                  void *                    userContext);
  252.  
  253. EXTERN_API( OSStatus )
  254. URLUpload                        (URLReference             urlRef,
  255.                                  const FSSpec *            source,
  256.                                  URLOpenFlags             openFlags,
  257.                                  URLSystemEventUPP         eventProc,
  258.                                  void *                    userContext);
  259.  
  260. EXTERN_API( OSStatus )
  261. URLNewReference                    (const char *            url,
  262.                                  URLReference *            urlRef);
  263.  
  264. EXTERN_API( OSStatus )
  265. URLDisposeReference                (URLReference             urlRef);
  266.  
  267. EXTERN_API( OSStatus )
  268. URLOpen                            (URLReference             urlRef,
  269.                                  FSSpec *                fileSpec,
  270.                                  URLOpenFlags             openFlags,
  271.                                  URLNotifyUPP             notifyProc,
  272.                                  URLEventMask             eventRegister,
  273.                                  void *                    userContext);
  274.  
  275. EXTERN_API( OSStatus )
  276. URLAbort                        (URLReference             urlRef);
  277.  
  278. EXTERN_API( OSStatus )
  279. URLGetDataAvailable                (URLReference             urlRef,
  280.                                  Size *                    dataSize);
  281.  
  282. EXTERN_API( OSStatus )
  283. URLGetBuffer                    (URLReference             urlRef,
  284.                                  void **                buffer,
  285.                                  Size *                    bufferSize);
  286.  
  287. EXTERN_API( OSStatus )
  288. URLReleaseBuffer                (URLReference             urlRef,
  289.                                  void *                    buffer);
  290.  
  291. EXTERN_API( OSStatus )
  292. URLGetProperty                    (URLReference             urlRef,
  293.                                  const char *            property,
  294.                                  void *                    propertyBuffer,
  295.                                  Size                     bufferSize);
  296.  
  297. EXTERN_API( OSStatus )
  298. URLGetPropertySize                (URLReference             urlRef,
  299.                                  const char *            property,
  300.                                  Size *                    propertySize);
  301.  
  302. EXTERN_API( OSStatus )
  303. URLSetProperty                    (URLReference             urlRef,
  304.                                  const char *            property,
  305.                                  void *                    propertyBuffer,
  306.                                  Size                     bufferSize);
  307.  
  308. EXTERN_API( OSStatus )
  309. URLGetCurrentState                (URLReference             urlRef,
  310.                                  URLState *                state);
  311.  
  312. EXTERN_API( OSStatus )
  313. URLGetError                        (URLReference             urlRef,
  314.                                  OSStatus *                urlError);
  315.  
  316. EXTERN_API( OSStatus )
  317. URLIdle                            (void);
  318.  
  319. EXTERN_API( OSStatus )
  320. URLGetFileInfo                    (StringPtr                 fName,
  321.                                  OSType *                fType,
  322.                                  OSType *                fCreator);
  323.  
  324.  
  325. #if PRAGMA_STRUCT_ALIGN
  326.     #pragma options align=reset
  327. #elif PRAGMA_STRUCT_PACKPUSH
  328.     #pragma pack(pop)
  329. #elif PRAGMA_STRUCT_PACK
  330.     #pragma pack()
  331. #endif
  332.  
  333. #ifdef PRAGMA_IMPORT_OFF
  334. #pragma import off
  335. #elif PRAGMA_IMPORT
  336. #pragma import reset
  337. #endif
  338.  
  339. #ifdef __cplusplus
  340. }
  341. #endif
  342.  
  343. #endif /* __URLACCESS__ */
  344.  
  345.